﻿using System;

namespace CannedHeater.Model.Utilities.Pachube
{
    /// <summary>
    /// Represents a data block fetched from a Pachube XML document
    /// </summary>
    public class PachubeData
    {
        /// <summary>
        /// The current value of the pachube data block
        /// </summary>
        /// <remarks>Double can be Double.NaN in case of unknown current value</remarks>
        public SerializableKeyValuePair<DateTime, double> CurrentValue { get; private set; }
        /// <summary>
        /// Max value of pachube data block
        /// </summary>
        /// <remarks>Can be NaN if unknown</remarks>
        public double MaxValue { get; private set; }
        /// <summary>
        /// Min value of pachube data block
        /// </summary>
        /// <remarks>Can be NaN if unknown</remarks>
        public double MinValue { get; private set; }
        /// <summary>
        /// The unit that is used for the data
        /// </summary>
        public string Unit { get; private set; }
        /// <summary>
        /// The datapoints of the pachube data block
        /// </summary>
        public SerializableKeyValuePair<DateTime, double>[] TimeValuePairs { get; private set; }

        /// <summary>
        /// Creates a new pachube data instance
        /// </summary>
        /// <param name="currentValue">CurrentValue of the pachube data block</param>
        /// <param name="maxValue">Max value of pachube data block</param>
        /// <param name="minValue">Min value of pachube data block</param>
        /// <param name="unit">The unit that is used for the data</param>
        /// <param name="timeValuePairs">The datapoints of the pachube data block</param>
        public PachubeData(SerializableKeyValuePair<DateTime, double> currentValue, double maxValue, double minValue, string unit, SerializableKeyValuePair<DateTime, double>[] timeValuePairs)
        {
            CurrentValue = currentValue;
            MaxValue = maxValue;
            MinValue = minValue;
            Unit = unit;
            TimeValuePairs = timeValuePairs;
        }
    }
}
